<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'维保工单列表'"></u-navbar>
		<uni-list>
			<uni-list-item direction="row" v-for="(item, index) in maintenanceRecordList" link :to="'/pages/index/workorder/information/info?ucId='+item.ucId" :key="item.ucId">
				<!-- 自定义 body -->
				<view slot="body" class="slot-box slot-text" style="line-height: 22px;">
					<view>工单名称: {{item.name}}</view>
					<view>维保人员: {{item.designeeName}}</view>
					<view>业主企业: {{item.enterpriseName}}</view>
				</view>
			</uni-list-item>
		</uni-list>
		<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText"  />
		<u-back-top :scroll-top="scrollTop"></u-back-top>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				maintenanceRecordList: [],
				pageNum:0,
				finished:false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多数据了'
				},
				scrollTop:0
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onShow() {
			this.initView()
		},
		methods: {
			initView() {
				this.maintenanceRecordList = []
				this.pageNum = 0
				this.getInMaintenanceRecordPage()
			},
			//获取维保工单分页信息数据
			getInMaintenanceRecordPage(){
				this.pageNum++
				let _this = this
				return new Promise((resolve, reject) => {
					_this.utils.request("/api/app/maintenanceRecord/getInMaintenancePage", {pageNum:this.pageNum,pageSize:10}, "post", "app", true).then(res => {
						_this.maintenanceRecordList.push(...res.data.list)
						_this.finished = (res.data.pageNum >= res.data.pages);
						if(_this.finished){
							_this.status = 'nomore';
						}
						resolve(res)
					}).catch(error => {
						reject(error)
					})
				})
			},
			onReachBottom() {
				if(this.finished) return ;
				this.status = 'loading';
				this.getBuildingPage().then(res=>{
					if(this.finished) this.status = 'nomore';
					else this.status = 'loading';
				}).catch(error=>{
					this.status = 'nomore';
				})
			}
		}
	}
</script>

<style>

</style>

